package org.example.mapper;


import org.apache.ibatis.annotations.*;
import org.example.pojo.Dept;

import java.util.List;

@Mapper
public interface DeptMapper {
    /*
    * 查询部门数据
    * */
    @Select("SELECT id, name, create_time, update_time FROM dept ORDER BY update_time DESC")
    List<Dept> findAll();


    /*
    * 根据ID删除部门数据
    * */
    @Delete("DELETE FROM dept WHERE id = #{id}")
    void deleteById(Integer id);

    /*
    * 新增部门数据
    * */
    @Insert("INSERT INTO dept(name, create_time, update_time) VALUES (#{name}, #{createTime}, #{updateTime})")
    void insert(Dept dept);

    /*
    * 根据ID查询部门数据
    * */
    @Select("SELECT id, name, create_time, update_time FROM dept WHERE id = #{id}")
    Dept getById(Integer id);

    /*
    * 更新部门数据
    * */
    @Update("update dept set name = #{name},update_time = #{updateTime} where id = #{id}")
    void update(Dept dept);
}
